package cn.edu.nwpu.warehousemanagement.util.msgQueue;

import cn.edu.nwpu.warehousemanagement.util.LogUtil;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 预测定时任务
 *
 * @author Loadstar
 * @version 1.0
 */
@Component
public class PredictionScheduler {
    @Value("${custom.rabbitmq.predict-queue}")
    private String predictQueue;

    private final AmqpTemplate rabbitTemplate;

    public PredictionScheduler(AmqpTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    @Scheduled(cron = "${spring.task.scheduling.cron}")
    public void sendPredictionStartMessage() {
        String message = "Start prediction at " + new java.util.Date();
        rabbitTemplate.convertAndSend("", predictQueue, message);
        LogUtil.info(PredictionScheduler.class, "已发送预测开始消息: {}", message);
    }
}
